package ru.spb.osll.myfit.util.parser;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;


public class ResultSection implements IResultSection
{
    private final String name;

    private ArrayList<Integer> columnWidths = new ArrayList<Integer>();

    private List<String[]> rows = new LinkedList<String[]>();

    public ResultSection(String name)
    {
        this.name = name;
    }

    public void addRow(String... values)
    {
        rows.add(values);

        for(int i = 0; i < values.length; i++) {
            int valueLength = values[i].length();

            if(columnWidths.size() < (i + 1)) {
                columnWidths.add(valueLength);
            } else {
                if(valueLength > columnWidths.get(i)) {
                    columnWidths.set(i, valueLength);
                }
            }
        }
    }

    public String getName()
    {
        return name;
    }

    public List<String[]> getRows()
    {
        return rows;
    }

    public ArrayList<Integer> getColumnWidth()
    {
        return columnWidths;
    }
}
